﻿// <copyright file="TopListUpdateDaemon.cs" company="Ecole Normale Supérieure">
// Released under GPLv2
// </copyright>
// <summary>Contains a daemon to keep the best kings list regularily updated.</summary>

namespace Sqwarea.Batch
{
    using Lokad.Cloud.ServiceFabric;
    using Sqwarea.GameLogic.TopList;

    /// <summary>
    /// Scheduled service as a daemon for updating the best kings list from time to time
    /// </summary>
    [ScheduledServiceSettings(
        AutoStart = true,
        ProcessingTimeoutSeconds = GlobalParameters.TopListUpdateDaemonTimeOutSeconds,
        TriggerInterval = GlobalParameters.TopListUpdateDaemonIntervalSecond)]
    public class TopListUpdateDaemon : ScheduledService
    {
        /// <summary>
        /// Gets or sets top list provider, needed to be injected by AutoFac
        /// </summary>
        public ITopListProvider TopListProvider { get; set; }

        /// <summary>
        /// Scheduled run of a method that update the best kings list and clean up intermediate buffers
        /// </summary>
        protected override void StartOnSchedule()
        {
            this.TopListProvider.Condensation();
        }
    }
}
